<?php

namespace Plugins\ApiDoc;


class Install
{

    public static function run(): void
    {
        $annotations = BASE_PATH . '/config/autoload/annotations.php';
        $annotationsContent = file_get_contents($annotations);

        $annotationsContent = strtr($annotationsContent, [
            "            'Plugins\ApiDoc\Attributes\Api'" => "//            'Plugins\ApiDoc\Attributes\Api'",
            "            'Plugins\ApiDoc\Attributes\ApiQuery'" => "//            'Plugins\ApiDoc\Attributes\ApiQuery'",
            "            'Plugins\ApiDoc\Attributes\ApiBody'" => "//            'Plugins\ApiDoc\Attributes\ApiBody'",
            "            'Plugins\ApiDoc\Attributes\ApiReturn'" => "//            'Plugins\ApiDoc\Attributes\ApiReturn'",
        ]);

        file_put_contents($annotations, $annotationsContent);

        echo "===============================================================\n";
        echo "ApiDoc 安装成功。\n";
        echo "示例代码查看 ApiDoc/Controller/DemoController.php。\n";
        echo "示例效果查看文档访问地址。\n";
        echo "文档访问地址： /api-doc\n";
        echo "===============================================================\n";
    }
}